﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "QuestionLib")]
    public class QuestionLibInfo : IDetach
    {
        public QuestionLibInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private int _sectionid = 0;
        private string _title = "";
        private int _score = 0;
        private double _diffcoe = 0;
        private DateTime _addtime = DateTime.Now;
        private int _type = 0;
        private int _usetimes = 0;
        private string _keyword = "";

        public int ChapterIdFake { get; set; }

        private EntityRef<QuestionAnswerInfo> _questionAnswerInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_questionAnswerInfo", ThisKey = "Id", OtherKey = "Qid", IsForeignKey = false)]
        [XmlIgnore]
        public QuestionAnswerInfo QuestionAnswerInfo
        {
            get { return _questionAnswerInfo.Entity; }
            set
            {
                _questionAnswerInfo.Entity = value;
                if ((value != null))
                {
                    value.QuestionLibInfo = this;
                }
            }
        }


        private EntitySet<RadioChoicesInfo> _radioChoicesInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_radioChoicesInfo", ThisKey = "Id", OtherKey = "Rid")]
        public EntitySet<RadioChoicesInfo> RadioChoicesInfo
        {
            get { return this._radioChoicesInfo; }
            set { this._radioChoicesInfo.Assign(value); }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 节ID
        /// </summary>
        [Column]
        [DisplayName("节")]
        public int SectionId
        {
            set { _sectionid = value; }
            get { return _sectionid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("题目")]
        [Required(ErrorMessage = "必须填写")]
        public string Title
        {
            set { _title = value; }
            get { return _title; }
        }
        /// <summary>
        /// 分值
        /// </summary>
        [Column]
        [DisplayName("分值")]
        public int Score
        {
            set { _score = value; }
            get { return _score; }
        }
        /// <summary>
        /// 难度系数
        /// </summary>
        [Column]
        [DisplayName("难度系数")]
        public double DiffCoe
        {
            set { _diffcoe = value; }
            get { return _diffcoe; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime AddTime
        {
            set { _addtime = value; }
            get { return _addtime; }
        }
        /// <summary>
        /// 0单项1多项2判断3论述4思考
        /// </summary>
        [Column]
        [DisplayName("题目类型")]
        public int Type
        {
            set { _type = value; }
            get { return _type; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int UseTimes
        {
            set { _usetimes = value; }
            get { return _usetimes; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        [DisplayName("关键字")]
        public string Keyword
        {
            set { _keyword = value; }
            get { return _keyword; }
        }
        public void Detach()
        {
            _questionAnswerInfo = default(EntityRef<QuestionAnswerInfo>);
            _radioChoicesInfo = new EntitySet<RadioChoicesInfo>();
        }
        #endregion Model

    }
}
